home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Devices / CDROMDriveCheck / CDROMDriveCheck.c next >
Encoding:
C/C++ Source or Header  |  1992-07-15  |  1.7 KB  |  75 lines  |  [TEXT/MPS ]

  1. /*
  2. File: CDROMDriveCheck.c
  3.  
  4. What's this?
  5. An MPW c tool that checks to see which SCSI IDs are AppleCD SC drives.  It
  6. makes a status call(97) to the AppleCD SC driver (only works with this 
  7. driver).  On exit from the status call, the byte at csParam+1 contains a 
  8. bit field with bits 7 - 0 corresponding to SCSI IDs 7 - 0.  That is, a 
  9. value of 10000010 means there are two AppleCD SCs attached, with SCSI 
  10. IDs 7 and 1.
  11.  
  12. Code notes:
  13. As the Blue Öyster Cult says, I'm making a career of evil:  the refnum is 
  14. hard-coded, which would cause Clarus to commence to bitin' on my kneecaps 
  15. (dogcows aren't very tall) were s/he to find out.
  16.  
  17. Further references:
  18. Apple CD SC™ Developers Guide, Revised Edition, Macintosh CD-ROM device 
  19. driver status calls section.   It's available from APDA.
  20.  
  21. Mark Baumwell 4/1/92
  22.  
  23. Build commands:
  24. C CDROMDriveCheck.c
  25. Link -w -t MPST -c 'MPS ' ∂
  26. CDROMDriveCheck.c.o ∂
  27. "{CLibraries}"CSANELib.o ∂
  28. "{CLibraries}"Math.o ∂
  29. "{CLibraries}"StdClib.o ∂
  30. "{Libraries}"Stubs.o ∂
  31. "{Libraries}"Runtime.o ∂
  32. "{Libraries}"Interface.o ∂
  33. "{Libraries}"ToolLibs.o ∂
  34. -o CDROMDriveCheck
  35.  
  36. */
  37.  
  38. #include    <types.h>
  39. #include    <stdio.h>
  40. #include    <files.h>
  41. #include    <osutils.h>
  42. #include    <strings.h>
  43. #include     <devices.h>
  44. #include    <sane.h>
  45.  
  46. main()
  47.  
  48. {
  49.    CntrlParam
  50.    pb;
  51.  
  52.    OSErr
  53.    err;
  54.    
  55.    /*Debugger();*/
  56.    
  57.    pb.ioCompletion = nil;
  58.    pb.ioVRefNum = 1;
  59.    pb.ioCRefNum = -39; /*Don't hard code refnum!!!*/
  60.    pb.ioNamePtr = nil;
  61.    pb.csCode = 97; // checks bit for a CD ROM
  62.  
  63.    err = PBStatus ((ParmBlkPtr) &pb, false);
  64.    if (err == noErr)
  65.    {
  66.    char byte2; /*in c, char is an 8 bit value*/
  67.    byte2 = ((char*) pb.csParam)[1];
  68.    printf ("the csParam (in decimal) = %i\n",(short)byte2);
  69.    }
  70.    else
  71.    {
  72.    printf ("error = %i\n",err);
  73.    }
  74. }
  75.